vim-jpのemoji情報をscrapbox json dataに変換
vim-jp slacklog/log-dataにあるvim-jpのemojiをscrapbox json dataに変換してみる
/takker-test-vim-jp
https://gyazo.com/fd67a845ff18e5f8023a2d5bbc8ab340
800個以上も絵文字があって草takker.icon
2021-07-08
15:47:25 Twemojiを標準のslack絵文字の画像に使った
10:22:15 /takker-vim-jp-emojiに入れた
10:05:16 emoji-というprefixを外した
別projectでemojiをhostingすることにした
既知の問題
/icons/done.icon標準のSlack絵文字が含まれていない
自前でデータを用意する必要がある
/icons/done.iconusernameと被ったりする
かぶらないようにemoji-というprefixを付けていたが、別のprojectを立ててそっちにemojiをおいてもよさそう
そうした
code:sh
deno run --allow-write=./emojis.json --allow-net=raw.githubusercontent.com,api.github.com,cdnjs.cloudflare.com -r=https://scrapbox.io/api/code/takker/vim-jpのemoji情報をscrapbox_json_dataに変換/script.ts https://scrapbox.io/api/code/takker/vim-jpのemoji情報をscrapbox_json_dataに変換/script.ts
code:script.ts
import {getEmojis} from './mod.ts';
import {getTwemoji} from '../Twitter絵文字を全て取得する/mod.js';
const customEmojis = await getEmojis();
const pages = customEmojis.map(({
name,
src,
alias,
}) =>{
const href = src ?? customEmojis.find(emoji => emoji.name === alias)?.src;
return {
title: name,
lines: [
name,
...(href ? [[${href}]] : []),
'',
...(alias ? [[${alias}]] : []),
'#custom',
],
};
});
const defaultEmojiPages = (await getTwemoji()).map(({
emoji,
shortcode,
url,
}) =>{
return {
title: shortcode.slice(1, -1),
lines: [
shortcode.slice(1, -1),
[${url}],
'',
'#default',
],
};
});
await Deno.writeTextFile('emojis.json', JSON.stringify({pages: ...defaultEmojiPages, ...pages}));
code:mod.ts
type Tree = {
tree: {
path: string;
url: string;
}[];
};
export async function getEmojis() {
const res = await fetch('https://raw.githubusercontent.com/vim-jp/slacklog/log-data/slacklog_data/emoji.json');
const data = (await res.json()) as Record<string, string>;
const emojis = Object.entries(data).map((name, ext) => {
if (ext.startsWith('alias:')) {
return {
name,
alias: ext.slice('alias:'.length),
};
} else {
return {
name,
src: https://raw.githubusercontent.com/vim-jp/slacklog/log-data/emojis/${encodeURIComponent(${name}${ext})},
};
}
});
return emojis;
}
#2021-07-02 00:25:10
#2021-07-01 19:06:58